package eleveController;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import model.BeanQuestionsRepondues;
import model.Question;
import model.Utilisateur;

/**
 * Servlet implementation class ServletResultEleve
 */
@WebServlet("/ServletResultEleve")
public class ServletResultEleve extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ServletResultEleve() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		HttpSession session = request.getSession(true);
		
		Utilisateur utilisateurCourant = (Utilisateur)session.getAttribute("Usersession");
		
		//si l'utilisateur est loger et que c'est un prof on lui donne accés à l'espace prof, sinon on le renvoi sur la page d'authentification
		if(utilisateurCourant != null)
		{
			RequestDispatcher dispatcher = request.getRequestDispatcher("eleve/homeEleve.jsp");
			dispatcher.forward(request,response);
		}
		else
		{
			String strDispatch = "/Test_Projet_QCM/Authentification";
			response.sendRedirect(strDispatch);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
